import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

final class cls_b extends cls_a {

    private int p;
    int l;
    private String q;
    int m;
    int n;
    int o;
    private Font r;
    private int s;
    private static String t[] = new String[110];

    cls_b(int i, int j, String s1, int k) {
        super(i, j);
        r = Font.getFont(0, 0, 8);
        s = 0xffffff;
        a(s1, 0);
    }

    cls_b(int i, int j, String s1, int k, int ai[]) {
        super(i, j, ai);
        r = Font.getFont(0, 0, 8);
        s = 0xffffff;
        a(s1, 0);
    }

    private void a(String s1, int i) {
        for (int j = 0; j < super.d; j++) {
            l = Math.max(l, super.j[0][j] + super.i[0][j]);
            p = Math.max(p, super.k[0][j] + super.h[0][j]);
        }

        q = s1;
        m = i;
        l = 18;
        n = l + 1;
        p = p >> 1;
    }

    final void a(Graphics g, String s1, int i, int j, int k) {
        int i1 = 0;
        int j1 = o;
        String s2 = s1;
        if (s2.length() > 2) {
            for (int l1 = 1; l1 <= s2.length(); l1++) {
                if (l1 > 1 && s2.substring(l1 - 1, l1).equals("|")) {
                    String s5 = s2.substring(0, l1 - 1);
                    int k2 = i1;
                    i1++;
                    t[k2] = s5;
                    s2 = s2.substring(l1);
                    l1 = 0;
                }
                if (l1 != 0 && r.stringWidth(s2.substring(0, l1)) > j1) {
                    String s6 = s2.substring(0, l1 - 1);
                    int l2 = i1;
                    i1++;
                    t[l2] = s6;
                    s2 = s2.substring(l1 - 1);
                    l1 = 0;
                }
            }

            if (s2.length() > 0) {
                int i2 = i1;
                i1++;
                t[i2] = s2;
            }
        } else {
            i1++;
            t[0] = s2;
        }
        int j2 = g.getColor();
        g.setFont(r);
        if (Spore.e && s1.equals("More Games")) {
            g.setColor(0, 255, 0);
        } else {
            g.setColor(s);
        }
        if (i1 == 1) {
            if ((k & 2) != 0) {
                j -= r.getHeight() / 2;
            }
            if ((k & 1) != 0) {
                i -= (s1.length() * 14) / 2;
            }
            if ((k & 8) != 0) {
                i -= s1.length() * 14;
            }
            if ((k & 0x20) != 0) {
                j -= r.getHeight();
            }
            g.drawString(s1, i, j, 0);
        } else {
            int is1;
            for (int i3 = 0; i3 < i1; i3++) {
                try {
                    g.drawString(t[i3], i, j + i3 * 18, k);
                    continue;
                }
                catch (Exception _ex) {
                    is1 = i;
                }
                int k1 = j;
                if ((k & 1) != 0) {
                    is1 = i - (t[i3].length() * 14) / 2;
                }
                if ((k & 8) != 0) {
                    is1 -= t[i3].length() * 14;
                }
                if ((k & 2) != 0) {
                    k1 = j - r.getHeight() / 2;
                }
                if ((k & 0x20) != 0) {
                    k1 -= r.getHeight();
                }
                g.drawString(t[i3], is1, k1 + i3 * 18, 0);
            }

        }
        g.setColor(j2);
    }

    public static String a(String s1) {
        return s1;
    }

    static String b(String s1) {
        return s1;
    }

    static int c(String s1) {
        return s1.length() * 14;
    }

    static int d(String s1) {
        return s1.length() * 14;
    }

    final int e(String s1) {
        int i;
        label0:
        {
            i = 0;
            if (s1.length() > 2) {
                for (int j = 1; j <= s1.length(); j++) {
                    if (j > 1 && s1.substring(j - 1, j).equals("|")) {
                        i++;
                        s1 = s1.substring(j);
                        j = 0;
                    }
                    if (j != 0 && r.stringWidth(s1.substring(0, j)) > o) {
                        i++;
                        s1 = s1.substring(j - 1);
                        j = 0;
                    }
                }
                // TODO Remove label break
                if (s1.length() <= 0)
                    break label0;
            }
            i++;
        }
        return i * l;
    }

    final int a(char c1) {
        int i = q.indexOf(c1);
        if ((i) >= 0)
            return i;
        if (Character.isLowerCase(c1))
            return q.indexOf(Character.toUpperCase(c1));
        if (Character.isUpperCase(c1))
            return q.indexOf(Character.toLowerCase(c1));
        else
            return i;
    }

}